
import { _decorator, Component, Node, UITransform, Sprite, color, Color } from 'cc';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = maskLayer
 * DateTime = Fri May 06 2022 16:59:55 GMT+0800 (中国标准时间)
 * Author = laozhou
 * FileBasename = maskLayer.ts
 * FileBasenameNoExtension = maskLayer
 * URL = db://assets/ccc3-framework-core/ui/maskLayer.ts
 * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
 *
 */

@ccclass('maskLayer')
export class maskLayer extends Component {
    @property(Node)
    mask: Node = null;

    start() {
        // [3]
        // this.scheduleOnce(() => {
        //     var maskTrans = this.mask.getComponent(UITransform);
        //     maskTrans.width = 750;
        //     maskTrans.height = 1334;
        // }, 0.1)
    }

    public setOpacity(opacity: number) {
        var maskSprite = this.mask.getComponent(Sprite);
        var color = new Color(maskSprite.color.r, maskSprite.color.g, maskSprite.color.b, opacity * 255);
        maskSprite.color = color;
    }

    // update (deltaTime: number) {
    //     // [4]
    // }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/decorator.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html
 */
